<%--
  Created by IntelliJ IDEA.
  User: leixiaolong
  Date: 2018/9/20
  Time: 下午5:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/include.jsp" %>

<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/static/css/rpt-condition.css" media="all" type="text/css">

    <style>
        .layui-form-label {
            width: 160px !important;
        }
    </style>

    <style>
        /* 防止下拉框的下拉列表被隐藏---必须设置--- */
        .layui-table-cell {
            overflow: visible !important;
        }

        /* 使得下拉框与单元格刚好合适 */
        td .layui-form-select {
            /*margin-top: -10px;*/
            /*margin-left: -15px;*/
            /*margin-right: -15px;*/
            /*solid: #d2d2d2;*/
            /*border: 1px;*/
        }

        /* 设置下拉框的高度与表格单元相同 */
        .layui-input, .layui-select, .layui-textarea {
            height: 30px !important;
        }

    </style>

    <style>
        .col-select-lg {
            margin-top: 10px;
            height: 30px;
            width: 300px;
            min-width: 200px;
            max-width: 600px;
        }

        .layui-input-inline {
            min-width: 300px;
            max-width: 600px;
        }
    </style>
</head>
<body class="layui-bg-gray">
<div class="layui-row layui-col-space10" style="margin: 10px; background-color: white">
    <div class="layui-container">
        <div class="layui-row layui-form">
            <div class="layui-col-md6 ">
                <div class="layui-form-item">
                    <label class="layui-form-label ">供货商编码：</label>
                    <input type="text" id="supplier_code" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6 ">
                <div class="layui-form-item">
                    <label class="layui-form-label ">供货商全称：</label>
                    <input type="text" id="supplier_name" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">供货商简称：</label>
                    <input type="text" id="abbr_name" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">营业执照号：</label>
                    <input type="text" id="organ_license" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">地址：</label>
                    <input type="text" id="address" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">法人名称：</label>
                    <input type="text" id="legal_name" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">证件类型：</label>
                    <div class="layui-input-inline">
                        <select class="layui-form-select" id="cert_type" lay-filter="cert_type">
                            <option value="" selected>全部</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">证件号码：</label>
                    <input type="text" id="cert_no" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <%--<div class="layui-col-md6">--%>
                <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">供货商类型：</label>--%>
                    <%--<div class="layui-input-inline">--%>
                        <%--<select class="layui-form-select" id="supp_type" lay-filter="supp_type">--%>
                            <%--<option value="" selected>全部</option>--%>
                        <%--</select>--%>
                    <%--</div>--%>
                <%--</div>--%>
            <%--</div>--%>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">主要经营范围：</label>
                    <input type="text" id="busi_main" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">联系人名称：</label>
                    <input type="text" id="link_man" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">联系人电话：</label>
                    <input type="text" id="link_phone" class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">联系人邮箱：</label>
                    <input type="text" id="link_email" class="layui-input-inline dom-add-input">
                </div>
            </div>
        </div>
    </div>
</div>

<div class="layui-btn-container" style="float: right; margin-right: 10%">
    <button class="layui-btn layui-btn-normal layui-btn-warm" lay-submit data-type="confirm">提交</button>
    <button class="layui-btn layui-btn-normal layui-btn-warm" lay-submit data-type="cancel">取消</button>
</div>
</body>

<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-select.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/table-data.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/tax-math.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/base-data.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/base-math.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-select.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-date.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/moment.js"></script>
<script>

    layui.use(["element", "form", "layer", "table", "jquery", "laydate"], function () {
        var element = layui.element, layer = layui.layer, table = layui.table, $ = layui.jquery;
        var form = layui.form, laydate = layui.laydate;
        //初始化渲染组件
        var isTrue = false;
        active = {
            confirm: function confirm() {
                request = {
                    "suppCode": $('#supplier_code').val(),
                    "suppName": $('#supplier_name').val(),
                    "abbrName": $('#abbr_name').val(),
                    "organLicense": $('#organ_license').val(),
                    "address": $('#address').val(),
                    "legalName": $('#legal_name').val(),
                    "certType": $('#cert_type').val(),
                    "certNo": $('#cert_no').val(),
                    "suppType": $('#supp_type').find("option:selected").val(),
                    "busiMain": $('#busi_main').val(),
                    "linkMan": $('#link_man').val(),
                    "linkPhone": $('#link_phone').val(),
                    "linkEmail": $('#link_email').val()
                };
                var reqBody = (JSON.stringify(request));

                $.ajax({
                    type: "POST",
                    url: "/base/insertSupplierInfo",
                    contentType: 'application/json',
                    dataType: 'json',//服务端返回数据类型
                    data: reqBody,
                    async: false,
                    success: function (data) {
                        debugger;
                        if (data.rspCode == 'RSP000000') {
                            isTrue = true;
                            layer.msg("录入供货商信息成功,单位编号:" + data.data);
                        } else {
                            layer.msg("录入供货商信息失败:" + data.rspMsg);
                            return;
                        }
                    },
                    error: function (data) {
                        console.log("系统异常:" + data);
                        layer.msg("系统异常,请联系管理员");
                    }
                });

                if (isTrue) {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.layui.table.reload("tab_supplier_apply", {});
                }
            },
            cancel: function cancel() {
                layer.msg("关闭弹出供货商录入");
                var parent_layer = parent.layer;
                var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引

                parent.layer.close(index);
                parent.layui.table.reload("tab_supplier_apply", {});
            }
        };

        form.on('submit', function (data) {
            var elem = data.elem;
            active[$(this).data("type")].call(this, elem);
        });

        form.render('select');
    });
</script>
</html>
